from tkinter import *
from tkinter.messagebox import askokcancel
from tkinter.filedialog import askopenfilename
from tkinter.colorchooser import askcolor
from tkinter.messagebox import askquestion, showerror
from tkinter.simpledialog import askfloat

demos = {
    '打开': askopenfilename,
    '颜色': askcolor,
    '查询': lambda: askquestion('注意', '您输入的指令是：rm *\n确认吗？'),
    '错误': lambda: showerror('错误', '错误的操作'),
    '输入': lambda: askfloat('输入', '请输入一个小数')
}


class Quitter(Frame):
    def __init__(self, parent=None):
        Frame.__init__(self, parent)
        self.pack()
        # 组件
        widget = Button(self, text="退出", command=self.quit)
        widget.pack(side=LEFT, expand=YES, fill=BOTH)

    def quit(self):
        ans = askokcancel("确认退出", "您确认要退出吗？")
        if ans: Frame.quit(self)


if __name__ == '__main__':
    Quitter().mainloop()
